<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
		/*声明函数*/
			function fun1(){
				console.log("声明函数");
			}
			fun1();
		/*函数表达式*/
			var fun2=function(){
				console.log("匿名函数赋值给变量");
			}
			fun2();
		/*参数*/
			function fun3(a,b){
				console.log(a+b);
			}
			fun3(6,9);
		/*参数可以封装到对象中*/
			function fun4(a){
				console.log(a);
			}
			var obj7={
				name:"陈明",
				age:18,
				address:"花果山17街道"
			};
			fun4(obj7);
		/*参数可以是函数*/
			function fun5(a){
				console.log(a);
			}
			fun5(function(){alert("hello")});
		/*返回值*/
			function fun6(a,b){
				return a+b;
			}
			var result=fun6(10,20);
			console.log(result);
		/*返回值可以是对象*/
			function fun7(){
				var obj8={name:"小小",age:128};
				return obj8;
			}
			var q=fun7();
			console.log(q);
		/*返回值可以是函数*/
			function fun8(){
				function fun9(){
					alert("这是fun9");
				}
				return fun9;
			}
			q=fun8();
			console.log(q);
		/*函数作用域*/
			var x=10;
			function fun10(){
				var x=20;/*局部变量*/
				console.log("fun10:"+x);
			}
			fun10();
			
			x=10;
			function fun11 () {
				console.log("fun11:"+x);
				x=30;     /*修改全局变量*/
			}
			fun11();
			console.log("全局:"+x);
			
			x=10;
			function fun12 (x) {
				console.log("fun12:"+x);
				x=30;     /*修改局部变量*/
			}
			fun12();
			console.log("全局:"+x);
		
		</script>
	</head>
	<body>
	</body>
</html>
